package hawk.example.bookstore.repository;

import glz.hawkframework.sql.condition.Condition;
import glz.hawkframework.sql.util.QueryWrapper;

import hawk.example.bookstore.po.PublisherPo;
import hawk.example.bookstore.update.PublisherColumnUpdate;
import hawk.example.bookstore.update.PublisherUpdate;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import javax.annotation.Nullable;

public interface PublisherRepository {
    void insert(PublisherPo publisherPo);

    void insertSelective(PublisherPo publisherPo);

    void insertMultiple(List<PublisherPo> publisherPos, int chunkSize);

    void insertMultiple(List<PublisherPo> publisherPos);

    void deleteByPrimaryKey(BigInteger publisherId, Long recordVersion);

    void updateByPrimaryKey(PublisherUpdate publisherUpdate, BigInteger publisherId, Long recordVersion);

    Optional<PublisherPo> getByPrimaryKey(BigInteger publisherId);

    /**
     * Throws an exception if found no required record by the primary key.
     */
    PublisherPo loadByPrimaryKey(BigInteger publisherId);

    /**
     * Throws the supplied exception if found no required record by the primary key.
     */
    <E extends Throwable> PublisherPo loadByPrimaryKey(BigInteger publisherId, Supplier<? extends E> exceptionSupplier) throws E;

    boolean existByPrimaryKey(BigInteger publisherId);

    /**
     * Throws an exception if the required record doesn't exist
     */
    void assertExistByPrimaryKey(BigInteger publisherId);

    /**
     * Throws the supplied exception if the required record doesn't exist
     */
    <E extends Throwable> void assertExistByPrimaryKey(BigInteger publisherId, Supplier<? extends E> exceptionSupplier) throws E;

    Optional<PublisherPo> queryOne(QueryWrapper queryWrapper);

    List<PublisherPo> queryMany(QueryWrapper queryWrapper);

    /**
     * Throws an exception if found no required record.
     */
    PublisherPo loadOne(QueryWrapper queryWrapper);

    /**
     * Throws the supplied exception if found no required record.
     */
    <E extends Throwable> PublisherPo loadOne(QueryWrapper queryWrapper, Supplier<? extends E> exceptionSupplier) throws E;

    long count(QueryWrapper queryWrapper);

    boolean exist(QueryWrapper queryWrapper);

    /**
     * Throws an exception if found no required record.
     */
    void assertExist(QueryWrapper queryWrapper);

    /**
     * Throws the supplied exception if found no required record.
     */
    <E extends Throwable> void assertExist(QueryWrapper queryWrapper, Supplier<? extends E> exceptionSupplier) throws E;

    boolean existOne(QueryWrapper queryWrapper);

    /**
     * Throws an exception if found no required record or found more than one record.
     */
    void assertExistOne(QueryWrapper queryWrapper);

    /**
     * Throws the supplied exception if found no required record or found more than one record.
     */
    <E extends Throwable> void assertExistOne(QueryWrapper queryWrapper, Supplier<? extends E> exceptionSupplier) throws E;

    long delete(@Nullable Condition condition);

    long update(PublisherColumnUpdate publisherColumnUpdate, @Nullable Condition condition);
}
